package cn.javase.base.multithread._03_守护线程;

public class _守护线程 {

    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable());
        t.setDaemon(true);
        t.start();
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(Thread.currentThread().getName() + "==>" + i);
        }
    }

    private static class MyRunnable implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i < 100; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName() + "==>" + i);
            }
        }
    }

}
